package com.jdk8.lambda_02;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;

public class FunctionDemo {

    public static <T,R> List<R> showList(List<T> list, Function<T,R> function) {
        ArrayList<R> rs = new ArrayList<>();
        for (T t : list) {
            rs.add(function.apply(t));
        }
        return rs;
    }


    public static void main(String[] args) {
        /*Function<String,Integer> function = new Function() {
            @Override
            public Object apply(Object o) {
                return null;
            }
        };*/
        List<String> list = Arrays.asList("aa", "sdcds", "dwd");
        List<Integer> lens = showList(list, (String str) -> str.length());
        System.out.println(lens.toArray());
    }
}
